//
//  DDPayHeaderView.m
//  DingDongZP
//
//  Created by 杨政涛 on 16/10/13.
//  Copyright © 2016年 51ledian.com. All rights reserved.
//

#import "DDPayHeaderView.h"

@implementation DDPayHeaderView

-(instancetype)initWithFrame:(CGRect)frame

{
    self = [super initWithFrame:frame];
    
    if (self) {
        
        UIView *headView = [[UIView alloc]init];
        headView.backgroundColor = [UIColor whiteColor];
        [self addSubview:headView];
        
        UIImageView *logoImage = [[UIImageView alloc]init];
        logoImage.layer.masksToBounds = YES;
        logoImage.image = [UIImage imageNamed:@"payAccountHeader"];
        [headView addSubview:logoImage];
        
        
        UILabel *titleLabel = [[UILabel alloc]init];
        titleLabel.textColor = COLOR_FONT_BLACK;
        titleLabel.font = [UIFont systemFontOfSize:15];
        titleLabel.text = @"充值账户";
        [headView addSubview:titleLabel];
        
        UILabel *phoneLabel = [[UILabel alloc]init];
        phoneLabel.textColor = COLOR_FONT_BLACK;
        phoneLabel.font = [UIFont systemFontOfSize:13];
        phoneLabel.text = [NSString stringWithFormat:@"%@",[DDLoginUserManager account]];
        phoneLabel.textAlignment = NSTextAlignmentRight;
        [headView addSubview:phoneLabel];
        
        UILabel *nameLabel = [[UILabel alloc]init];
        nameLabel.textColor = COLOR_FONT_LIGHT_GRAY;
        nameLabel.font = [UIFont systemFontOfSize:13];
        nameLabel.text = [NSString stringWithFormat:@"%@",[DDLoginUserManager accountName]];
        nameLabel.textAlignment = NSTextAlignmentCenter;
        [headView addSubview:nameLabel];
        
        
        WEAKSELF
        [headView mas_makeConstraints:^(MASConstraintMaker *make) {
           
            make.top.mas_equalTo(weakSelf).offset(14);
            make.left.right.bottom.mas_equalTo(weakSelf);
        }];
        
        
        [logoImage mas_makeConstraints:^(MASConstraintMaker *make){
            
            make.left.mas_equalTo(headView).offset(20);
            make.centerY.mas_equalTo(headView);
            make.width.height.equalTo(@(23));
        }];
        
        [titleLabel mas_makeConstraints:^(MASConstraintMaker *make){
            
            make.left.mas_equalTo(logoImage.mas_right).offset(10);
            make.centerY.mas_equalTo(headView);
        }];
        
        [phoneLabel mas_makeConstraints:^(MASConstraintMaker *make){
          
            make.top.mas_equalTo(headView).offset(20);
            make.right.mas_equalTo(headView).offset(-20);
        }];
        [nameLabel mas_makeConstraints:^(MASConstraintMaker *make){
            
            make.top.mas_equalTo(phoneLabel.mas_bottom).offset(5);
            make.right.mas_equalTo(phoneLabel);
            make.width.mas_equalTo(phoneLabel);
        }];
        
    }
    return self;
}

/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect {
    // Drawing code
}
*/
@end
